<?php

namespace app\admin\model\xiangmuzu;


use think\Model;
use think\Session;
/**
 *  项目组模型
 */
class Article extends Model{
    protected $name = 'yonghui_project';

    /**
     * 项目组详情
     */
    public static function detail($article_id){
        return self::get($article_id);
    }

    /**
     * 获取项目组列表
     */
    public function getList($serach){
        $sessionInfo=Session::get('yoshop_adminuser');
        if(!empty($serach['search'])){
            $where['name']=['like','%'.$serach['search'].'%'];
            $where['companyId']=['=',$sessionInfo['user']['company_id']];
        }else{
            $where['companyId']=['=',$sessionInfo['user']['company_id']];
        }
        return $this
            ->where($where)
            ->order(['createTime' => 'desc'])
            ->paginate(15, false, [
                'query' => request()->request()
            ]);
    }
    /**
     * 新增项目组
     */
    public function add($data){
        return $this->allowField(true)->save($data);
    }
    /**
     * 更新项目组信息
     */
    public function edit($data){
        return $this->allowField(true)->save($data) !== false;
    }
    /**
     * 软删除
     */
    public function setDelete(){
        return $this->allowField(true)->save(['status' => 2,'updateTime'=>time()]);
    }
    public function recover(){
        return $this->allowField(true)->save(['status' => 1,'updateTime'=>time()]);
    }
}